const express = require("express");
const fs = require("fs")

const app = express()

app.use(express.static("./www"))

app.get("/getGoods", (req,res,next)=>{

    fs.readFile("./data/goods.json", "utf-8", (err,data)=>{
        if(err){
            res.send(JSON.stringify({
                code:0,
                msg:"数据请求失败",
                data:null
            }))
        }else{
            res.send(JSON.stringify({
                code:1,
                msg:"数据请求成功",
                data:JSON.parse(data)
            }))
        }
    })

})

app.listen(3000);